package cn.edu.sdjzu.xg11.domain;

import java.io.Serializable;
import java.sql.Date;
import java.util.Collection;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Past;
import javax.validation.constraints.Size;


public final class GraduateProject implements Comparable<GraduateProject>,Serializable{
	private static Integer nextID = 11;
	private Integer id;

//	@Pattern(regexp="[^.w]{5,40}", message="题目应为5-40字符符")	//与下一行作用相同
//	@Size(min=5, max=40, message = "题目应为5-40字符")  //需要bean-validator包
//	如果配置了资源文件(src/conf/i18n/messages.properties)，/bysj/WebContent/WEB-INF/bysj-servlet.xml
//	则显示Size.graduateProject.title对应的资源信息
	@Size(min=5, max=40, message = "题目应为5-40字符")  //需要bean-validator包。

	private String title;
	//限选专业
	@NotNull(message="请选择限选专业")
	private Collection<Major> limitedToMajor;
	//类别
	private ProjectCategory projectCategory;
	//类型
	private ProjectType projectType;
	//性质
	//来源
	//审批状态
	private GraduateProjectStatus graduateProjectStatus;
	
	private Teacher teacher;

	//初始化块
	{
		this.id = nextID;
		nextID++;
//		System.out.println("N");
	}
	
	public GraduateProject() {	
		
		super();
//		System.out.println("C");
		
	}
	
	public GraduateProject(Integer id) {
		this.setId(id);
	}
	

	public void setGraduateProjectStatus(GraduateProjectStatus graduateProjectStatus) {
		this.graduateProjectStatus = graduateProjectStatus;
	}

	public GraduateProjectStatus getGraduateProjectStatus() {
		return graduateProjectStatus;
	}

	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public Collection<Major> getLimitedToMajor() {
		return limitedToMajor;
	}
	public void setLimitedToMajor(Collection<Major> limitedToMajor) {
		this.limitedToMajor = limitedToMajor;
	}
	
	
	
	public ProjectCategory getProjectCategory() {
		return projectCategory;
	}

	public void setProjectCategory(ProjectCategory projectCategory) {
		this.projectCategory = projectCategory;
	}

	public ProjectType getProjectType() {
		return projectType;
	}
	public void setProjectType(ProjectType projectType) {
		this.projectType = projectType;
	}
	public Teacher getTeacher() {
		return teacher;
	}
	public void setTeacher(Teacher teacher) {
		this.teacher = teacher;
	}

	
	
	public GraduateProject(String title, Collection<Major> limitedToMajor,
			ProjectCategory projectCategory, ProjectType projectType,
			GraduateProjectStatus graduateProjectStatus, Teacher teacher) {
		super();
		this.title = title;
		this.limitedToMajor = limitedToMajor;
		this.projectCategory = projectCategory;
		this.projectType = projectType;
		this.graduateProjectStatus = graduateProjectStatus;
		this.teacher = teacher;
	}

	@Override
	public int compareTo(GraduateProject o) {
		// TODO Auto-generated method stub
		return this.id-o.id;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		final GraduateProject other = (GraduateProject) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}

	/**
	 * Constructs a <code>String</code> with all attributes
	 * in name = value format.
	 *
	 * @return a <code>String</code> representation 
	 * of this object.
	 */
	public String toString()
	{
	    final String TAB = "    ";
	    
	    String retValue = "";
	    
	    retValue = "GraduateProject ( "
	        + super.toString() + TAB
	        + "id = " + this.id + TAB
	        + "title = " + this.title + TAB
	        + "limitedToMajor = " + this.limitedToMajor + TAB
	        + "projectCategrory = " + this.projectCategory + TAB
	        + "projectType = " + this.projectType + TAB
	        + "teacher = " + this.teacher + TAB
	        + " )";
	
	    return retValue;
	}
	
	public static void main(String[] args){
		GraduateProject g1 = new GraduateProject();
		GraduateProject g2 = new GraduateProject();
		System.out.println(g1);
		System.out.println(g2);
		
	}
}
